<!-- Dom模板 -->
<template>
    
  <div class="xiugai">
        <!-- Dom内容 -->
        
    <div class="xiugaibox">
      <div class="xiugai_head">
        <p class="iconfont icon-iconfontyoujiantou-zuo" @click="close"></p>
        <h3>修改昵称</h3>
      </div>
      <div class="name">
        <input
          type="text"
          name=""
          id=""
          placeholder="请输入用户名"
          v-model="username"
        />
      </div>
      <button @click="xiugai">提交</button>
    </div>
      
  </div>
</template>

<script>
// import a from './a'; // 引入组件
export default {
  data() {
    return {
      msg: "测试",
      username: this.$store.state.login.loginuser.name,
    };
  }, // 生命周期 - 创建完成（访问当前this实例）
  created() {}, // 生命周期 - 挂载完成（访问DOM元素）
  mounted() {}, // Vue方法定义
  methods: {
    close() {
      this.$parent.back();
    },
    xiugai() {
      let id = sessionStorage.getItem("userId");
      this.$store
        .dispatch("login/eidt", {
          userid: id,
          type: "names",
          name: this.username,
        })
        .then((res) => {
          if (res.code === 200) {
            this.$store.dispatch('login/getUser',{userid:id})
            this.$parent.back();
          }
          
        });
    },
  },
};
</script>

<style scoped>
@import url("../../../static/fonts/iconfont.css");
.xiugai {
  width: 100vw;
  height: 100vh;
  background: white;
}
.xiugaibox {
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.02);
}
.xiugai_head {
  width: 100%;
  height: 1.466667rem;
  background: #f33a65;
  color: white;
  padding-top: 0.4rem;
  margin-bottom: 3.333333rem;
  position: relative;
}
.xiugai_head p {
  font-size: 0.746667rem;
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  line-height: 1.6rem;
}
.xiugai_head h3 {
  width: 100%;
  font-size: 0.586667rem;
  line-height: 0.826667rem;
  text-align: center;
}
.xiugaibox button {
  display: block;
  margin: 0 auto;
  width: 80%;
  height: 44px;
  line-height: 52px;
  border: none;
  background: #f33a65;
  color: white;
  font-size: 0.48rem;
  border-radius: 22px;
}
.xiugaibox .name {
  width: 75%;
  height: 1.6rem;
  margin: 0 auto;
  margin-bottom: 0.533333rem;
}
.xiugaibox .name input {
  width: 100%;
  height: 1rem;
  border: none;
  outline: none;
  border-bottom: 1px solid #cfcfcf;
  background: #fafafa;
  color: #b2b0b0;
}
</style>